package com.example.yuejianapp14.Activity.Activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.EditText;

import com.example.yuejianapp14.Activity.Adapter.CoachskAdapter;
import com.example.yuejianapp14.Activity.JavaBean.Coachask;
import com.example.yuejianapp14.Activity.Listener.CoachaskListener;
import com.example.yuejianapp14.Activity.Model.CoachModel;
import com.example.yuejianapp14.R;

import java.util.List;

public class CoachAskActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private List mDataList;
    private EditText uask;
    private Intent intent;
    private RecyclerView recyclerViewask;
    private Button askenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coach_ask);
        initViews();
        getData();
        initRecyclerView();
    }

        CoachaskListener coachaskListener = new CoachaskListener() {
            @Override
            public void onResponse(List<Coachask> beanList) {
                mDataList=beanList;
                CoachskAdapter coachskAdapter = new CoachskAdapter(CoachAskActivity.this,mDataList);
                recyclerView.setAdapter(coachskAdapter);
            }

            @Override
            public void onFail(String msg) {

            }
        };


    private void initViews(){
        uask=(EditText)findViewById(R.id.uask);
        recyclerViewask=(RecyclerView)findViewById(R.id.rv_coachask);
        askenter=(Button)findViewById(R.id.askenter);
    }

    private void getData(){
        CoachModel coachModel = new CoachModel();
        coachModel.coachask(getIntent().getStringExtra("coachid"),coachaskListener);
    }

    private void initRecyclerView() {
        recyclerView = (RecyclerView)findViewById(R.id.rv_coachask);
        recyclerView.setLayoutManager(new LinearLayoutManager(CoachAskActivity.this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

}
